import HTTP from '@/http/http'
const centerApi = import.meta.env.VITE_BASE_URL

class Api extends HTTP {
  // 用户列表
  getUserlist(params?: any) {
    return this.request({
      method: 'get',
      url: `${centerApi}/system/user/list`,
      params
    })
  }
  // 编辑用户
  editUser(data?: any) {
    return this.request({
      method: 'put',
      url: `${centerApi}/system/user`,
      data
    })
  }
  // 用户详情
  userDetail(params?: any) {
    return this.request({
      method: 'get',
      url: `${centerApi}/system/user/${params}`
    })
  }
  // 新增用户
  addUser(data?: any) {
    return this.request({
      method: 'post',
      url: `${centerApi}/system/user`,
      data
    })
  }
  //删除用户
  deletUser(params?: any) {
    return this.request({
      method: 'delete',
      url: `${centerApi}/system/user/${params}`
    })
  }
  // 角色列表
  getRolelist(params?: any) {
    return this.request({
      method: 'get',
      url: `${centerApi}/system/role/list`,
      params
    })
  }
  // 授权列表
  getTreeselect(params?: any) {
    return this.request({
      method: 'get',
      url: `${centerApi}/system/menu/treeselect`,
      params
    })
  }
  // 修改角色
  editRole(data?: any) {
    return this.request({
      method: 'put',
      url: `${centerApi}/system/role`,
      data
    })
  }
  // 角色详情
  roleDetails(params?: any) {
    return this.request({
      method: 'get',
      url: `${centerApi}/system/role/${params}`
    })
  }
  // 角色授权数据
  roleMenuTreeselect(params?: any) {
    return this.request({
      method: 'get',
      url: `${centerApi}/system/menu/roleMenuTreeselect/${params}`
    })
  }
  // 新增角色
  addRole(data?: any) {
    return this.request({
      method: 'post',
      url: `${centerApi}/system/role`,
      data
    })
  }
  //删除用户
  deletRole(params?: any) {
    return this.request({
      method: 'delete',
      url: `${centerApi}/system/role/${params}`
    })
  }
}
export default new Api()
